﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;

namespace SuaChuaCaiTao24H.en
{
    public partial class contact_us : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                Label5.Visible = false;
            }
        }

        protected void btnFeedBack_Click(object sender, EventArgs e)
        {
            //NoviFeedbackDataContext fb = new NoviFeedbackDataContext();
            // fb.SendFeedback(txtFullName.Text, txtPhone.Text, txtEmail.Text, txtAreaContent.Text);
            Label5.Visible = true;
            txtAreaContent.Text = "";
            txtEmail.Text = "";
            txtFullName.Text = "";
            txtPhone.Text = "";
        }
        public void Mail()
        {
            SmtpClient client = new SmtpClient();

            client.DeliveryMethod = SmtpDeliveryMethod.Network;

            client.EnableSsl = true;

            client.Host = "smtp.gmail.com";

            client.Port = 587;
            // setup Smtp authentication

            System.Net.NetworkCredential credentials =
                new System.Net.NetworkCredential("support@novi.com.vn", "nguyenmanh");

            client.UseDefaultCredentials = false;

            client.Credentials = credentials;

            MailMessage msg = new MailMessage();

            msg.From = new MailAddress("support@novi.com.vn");

            msg.To.Add(new MailAddress("ethanhgiang.hanoi@gmail.com"));

            msg.Subject = "Infomation contact from SUA CHUA CAI TAO 24H";
            msg.IsBodyHtml = true;
            string content = "Full name: " + txtFullName.Text + "<br/>" + "Phone: " + txtPhone.Text + "<br/>" + "Email: " + txtEmail.Text + "<br/>" + "Content: " + txtAreaContent.Text + "<br/>";

            msg.Body = string.Format("<html><head></head><body>" + content + "</body>");

            try
            {

                client.Send(msg);
                Label5.Visible = true;
                Dis();

            }

            catch (Exception ex)
            {
                //
            }

        }
        protected void Dis()
        {
            txtEmail.Text = "";
            txtFullName.Text = "";
            txtPhone.Text = "";
            txtAreaContent.Text = "";
        }
    }
}